<?php
class TeaInfoAction extends Action
{
    /**
    +----------------------------------------------------------
    *教师信息添加
    +----------------------------------------------------------
    */
   public  function teaadd()
   {
        $tea=M("teacher");
        $tea->create();
        $tea_result=$tea->add();
        if($tea_result)
        {
            $this->assign("jumpUrl","teaadd");
            $this->success("教师信息添加成功");
        }
        else
        {
              $this->display();
        }
   }
    /**
    +----------------------------------------------------------
    *教师信息列表
    +----------------------------------------------------------
    */
    public function tealist()
    {
         $tealist=M("teacher");
         $tealist_result=$tealist->field("tea_id,tea_name,tea_sex,tea_position,tea_phone,tea_email")->select();
         $this->assign("tealistshow",$tealist_result);
         $this->display();
    }
    /**
    +----------------------------------------------------------
    *教师信息编辑
    +----------------------------------------------------------
    */
     public function teaedit()
    {
        $teaedit=M("teacher");
        if(isset($_GET['e_id']))
        {          
            $e_id=$_GET['e_id'];
            $edit_result= $teaedit->where("tea_id=$e_id")->field("tea_name,tea_position,tea_phone,tea_email,tea_description")->limit(1)->find();
            $this->assign('e_id',$e_id);
            $this->assign('edit_result',$edit_result);
            $this->display(teaedit);
        }
        //更新类别信息
        if(isset($_POST['u_e_id']))
        {
            $u_e_id=$_POST['u_e_id'];
            $teaedit->create();
            $info=$teaedit->where("tea_id=$u_e_id")->save();
            if($info)
            {
                $this->assign("jumpUrl","tealist");
                $this->success("信息修改成功!");
            }

        }
     }
     /**
    +----------------------------------------------------------
    *删除教师信息
    +----------------------------------------------------------
    */
      public function teadel()
    {
        $teadel=M("teacher");
        if(isset($_GET['d_id']))
        {
            $d_id=$_GET['d_id'];
            $del_result=$teadel->where("tea_id=$d_id")->delete();
            if($del_result)
            {
                $this->assign("jumpUrl","__URL__/tealist");
                $this->success("信息删除成功!");
            }
        }

     }

}
?>
